Normalize ws root path
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 14 Feb 2017 20:04:24 +0000 (23:04 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 14 Feb 2017 20:12:55 +0000 (23:12 +0300)
closes #3586

src/cargo/util/important_paths.rs
tests/workspaces.rs

index 5ee44cf2006d2a345591e46ae6b94a631cf0e12a..97e7eed1ce912e50c35cd8a8bf6eace34b8ac5fd 100644 (file)
@@ -1,6 +1,7 @@
 use std::fs;
 use std::path::{Path, PathBuf};
 use util::{CargoResult, human};
+use util::paths;
 
 /// Iteratively search for `file` in `pwd` and its parents, returning
 /// the path of the directory.
@@ -38,7 +39,7 @@ pub fn find_root_manifest_for_wd(manifest_path: Option<String>, cwd: &Path)
                                   -> CargoResult<PathBuf> {
     match manifest_path {
         Some(path) => {
-            let absolute_path = cwd.join(&path);
+            let absolute_path = paths::normalize_path(&cwd.join(&path));
             if !absolute_path.ends_with("Cargo.toml") {
                 bail!("the manifest-path must be a path to a Cargo.toml file")
             }
index dc3860f273a7ae6915deba84d6365a8c1f5012bd..0ae7a609a79234eda75485bd53bd23ed5f5ad72d 100644 (file)
@@ -1102,6 +1102,39 @@ fn relative_path_for_member_works() {
     assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0));
 }
 
+#[test]
+fn relative_path_for_root_works() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+        [project]
+        name = "foo"
+        version = "0.1.0"
+        authors = []
+
+        [workspace]
+
+        [dependencies]
+        subproj = { path = "./subproj" }
+    "#)
+        .file("src/main.rs", "fn main() {}")
+        .file("subproj/Cargo.toml", r#"
+        [project]
+        name = "subproj"
+        version = "0.1.0"
+        authors = []
+    "#)
+        .file("subproj/src/main.rs", "fn main() {}");
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root())
+                    .arg("--manifest-path").arg("./Cargo.toml"),
+                execs().with_status(0));
+
+    assert_that(p.cargo("build").cwd(p.root().join("subproj"))
+                    .arg("--manifest-path").arg("../Cargo.toml"),
+                execs().with_status(0));
+}
+
 #[test]
 fn path_dep_outside_workspace_is_not_member() {
     let p = project("foo")